//
//  SignDayView.swift
//  TianTianBiTing
//
//  Created by Gox mac 2 on 2019/3/1.
//  Copyright © 2019 Gox_WallyDiao. All rights reserved.
//

import UIKit

class SignDayView: UIView {

    lazy var listenModel: [SignInListModel] = [{
        return SignInListModel()
        }()]
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.clear
        
        setData()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUI() {
        self.backgroundColor = .clear
        
        let lineView = UIView.init(frame: FRAME_CGFloat(10, 7, 210, 0.5))
        lineView.backgroundColor = RGB_Same(151, 1)
        self.addSubview(lineView)
        
        for i in 0..<self.listenModel.count {
            let backImageView = UIImageView.init(frame: FRAME_CGFloat(CGFloat(35 * i), 0, 20, 20))
            backImageView.image = IMAGE(name: returnImageStr(day: self.listenModel[i].day, signStatus: self.listenModel[i].signStatus))
            self.addSubview(backImageView)
        }
        
        
    }
    
    func setData() {
        WelfareRequestModel.loadSignInListData(parameters: ["userId":String.getUserId(), "flg":0]) { (success, message, model) in
            if success && model != nil {
                self.listenModel = model![0].subSignInBo!
                self.setUI()
            }
        }
        
    }
    
    func returnImageStr(day:Int,signStatus:Int) -> String {
        if signStatus == 1 {
            return "signDayY\(day)"
        } else {
            return "signDayN\(day)"
        }
    }


}
